package com.wc.fortnight_blue_bridge.Q240518.B_数学魔术家;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/5/18 19:10
 * @description https://www.lanqiao.cn/problems/18479/learning/?contest_id=185
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static char[] s;
    static int n;
    static int[] numId = new int[10];

    public static void main(String[] args) {
        s = (" " + sc.next()).toCharArray();
        n = s.length - 1;
        Arrays.sort(s, 1, n + 1);
        for (int i = 1, j = n; i < j; i++, j--) {
            char tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
        print();
        for (int i = 1, j = n; i < j; i++, j--) {
            char tmp = s[i];
            s[i] = s[j];
            s[j] = tmp;
        }
        out.print(" ");
        int first = 1;
        while (s[first] == '0') first++;
        char tmp = s[first];
        s[first] = s[1];
        s[1] = tmp;
        print();

        out.flush();
    }

    static void print() {
        for (int i = 1; i <= n; i++) {
            out.print(s[i]);
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
